﻿@using BonjourQuotation.UI.Models.PartialModel
@model OperationVHotelGridViewModel

<script type="text/javascript">
    var VendorHotelModel;
    debugger;
    LoadVendorHotelGrid();

    function LoadVendorHotelGrid() {
        VendorHotelModel = $(@Html.Raw(Json.Encode(Model))).JSModel();
        var VendorHotelcolumnHeaders = [];
        var VendorHotelcolumns = [];
        var VendorHotelcolWidth = [];
       // var VendorHotelStatus = [];

        // Init status
        //$(VendorHotelModel[0].VHotelStatus).each(function (index, elem) {
        //    VendorHotelStatus.push(elem.Text);
        //});

        VendorHotelcolumnHeaders.push("Vendor");
        VendorHotelcolumns.push({ data: "VHotelVendorName", type: "text", readOnly: true });
        VendorHotelcolWidth.push(632);

        VendorHotelcolumnHeaders.push("Arrival");
        VendorHotelcolumns.push({ data: "VHotelArrivalDate", type: "date", dateFormat: 'D, dd/M/yy', readOnly: true });
        VendorHotelcolWidth.push(140);

        VendorHotelcolumnHeaders.push("Departure");
        VendorHotelcolumns.push({ data: "VHotelDepartureDate", type: "date", dateFormat: 'D, dd/M/yy', readOnly: true });
        VendorHotelcolWidth.push(140);

        //VendorHotelcolumnHeaders.push("Status");
        //VendorHotelcolumns.push({ data: "VHotelStatus", type: "dropdown", source: VendorHotelStatus });
        //VendorHotelcolWidth.push(160);

        VendorHotelcolumnHeaders.push("Preview");
        VendorHotelcolumns.push({ data: "VHotelPreviewHtml", renderer: "html" });
        VendorHotelcolWidth.push(80);

        VendorHotelcolumnHeaders.push("Overwrite");
        VendorHotelcolumns.push({ data: "VHotelOverwriteHtml", renderer: "html" });
        VendorHotelcolWidth.push(80);

        VendorHotelcolumnHeaders.push("Vendor Confirm");
        VendorHotelcolumns.push({ data: "VHotelVConfHtml", renderer: "html" });
        VendorHotelcolWidth.push(110);

        VHotelRedColorRendererForNegative = function (instance, td, row, col, prop, value, cellProperties) {
            Handsontable.renderers.NumericRenderer.apply(this, arguments);
            td.style.color = 'red';
        };

        var VendorHoteldata = VendorHotelModel[0].Rows;
       
            $("#OperVendorHotelGrid").show();
            $('#OperVendorHotelGrid').handsontable({
                data: VendorHoteldata,
                minSpareRows: 0,
                colHeaders: VendorHotelcolumnHeaders,
                colWidths: VendorHotelcolWidth,
                contextMenu: false,
                manualColumnResize: true,
                manualRowResize: true,
                columns: VendorHotelcolumns,
                cells: function (row, col, prop) {
                    var Cellinstance = this;
                    if (Cellinstance.renderer == Handsontable.renderers.NumericRenderer && Cellinstance.instance.getDataAtCell(row, col) < 0) {
                        Cellinstance.renderer = VHotelRedColorRendererForNegative;
                    }
                }
                //  isEmptyRow: customIsEmptyRow,
            });
        
    }
</script>

@using (Ajax.BeginForm("UpdateVendorHotel", "Operation", new AjaxOptions() { HttpMethod = "Post", UpdateTargetId = "VendorHotelDiv", InsertionMode = InsertionMode.Replace }, new { enctype = "multipart/form-data", id = "OperationVendorHotelGridForm" }))
{
    if(Model.Rows.Count > 0)
    { 
        <div id="OperVendorHotelGrid" class="handsontable" style="width: 1185px; height:130px; overflow:auto; display:none;"></div>
        @*<button class="btm btn-success" id="BusTabUpdate" type="submit">Save</button>*@
        <input type="button" id="GVendorListReportBtn" class="btn14  btn60" value="Preview">
    }
}





